import java.util.Comparator;
import java.util.Objects;

/**
 * @Author 12629
 * @Description：
 */
class Card implements Comparable<Card>{
    public int rank;	// 数值
    public String suit;	// 花色

    public Card(int rank, String suit) {
        this.rank = rank;
        this.suit = suit;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Card card = (Card) o;
        return rank == card.rank && Objects.equals(suit, card.suit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rank, suit);
    }

    @Override
    public int compareTo(Card o) {
        return this.rank - o.rank;
    }
}

class RankComparator implements Comparator<Card> {

    @Override
    public int compare(Card o1, Card o2) {
        return o1.rank-o2.rank;
    }
}

class SuitComparator implements Comparator<Card> {

    @Override
    public int compare(Card o1, Card o2) {
        return o1.suit.compareTo(o2.suit);
    }
}


public class Test2 {

    public static void main(String[] args) {
        RankComparator rankComparator = new RankComparator();
        Card card = new Card(2, "♠");
        Card card2 = new Card(1, "♣");
        System.out.println(rankComparator.compare(card, card2));

        SuitComparator suitComparator = new SuitComparator();
        System.out.println(suitComparator.compare(card,card2));
    }
    public static void main1(String[] args) {
        Card card = new Card(1, "♠");
        Card card2 = new Card(1, "♠");
        //System.out.println(card == card2);
        System.out.println(card.equals(card2));
        System.out.println(card2.compareTo(card));
    }

}
